package com.itheima.reggie.mapper;

import com.itheima.reggie.dto.SetmealDto;
import com.itheima.reggie.entity.Setmeal;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

public interface SetmealMapper {

    //根据套餐名称差寻所用套餐数据
    List<Setmeal> findAll(@Param("name") String name);

    @Select("select count(*) from setmeal where category_id =#{categoryId} and is_deleted=0")
    Integer countByCid(@Param("categoryId") Long categoryId);



    @Insert("insert into setmeal values(null,#{categoryId},#{name},#{price},#{status},#{code},#{description},#{image},#{createTime},#{updateTime},#{createUser},#{updateUser},0)")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    Integer save(SetmealDto setmealDto);

    //查询指定ID列表数据中含有启用套餐的个数
    Integer countByIds(@Param("ids") List<Long> ids);

    //删除指定多个id的套餐(未删除)
    Integer deleteByIds(@Param("ids") List<Long> ids,
                        @Param("updateUser") Long updateUser,
                        @Param("updateTime")LocalDateTime updateTime);





}
